<template>
  <div>
    <div class="container">
      <div class="container-search">
        <!-- <div class="container-search-top"></div> -->
        <div class="container-search-bottom">
          <!-- 筛选条件 -->
          <div class="search">
            <div class="search-item">
              <el-input
                v-model="params.name"
                placeholder="请输入单位名称"
                clearable
                maxlength="25"
                class="search-input"
              />
            </div>
            <div class="search-item">
              <el-cascader
                v-model="params.region"
                placeholder="请选择行政区划"
                :options="options"
                filterable
                clearable
                @change="handlerregion"
                :props="areaprops"
              />
            </div>
            <div class="search-item">
              <el-select
                v-model="params.typeId"
                placeholder="请选择单位类型"
                clearable
                class="search-input"
              >
                <el-option
                  v-for="dict in unittypeList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </div>
            <div class="search-item">
              <el-select
                v-model="params.levelId"
                placeholder="请选择单位级别"
                clearable
                class="search-input"
              >
                <el-option
                  v-for="dict in unitlevelList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </div>
            <div class="search-item">
              <el-select
                v-model="params.industryId"
                placeholder="请选择所属行业"
                clearable
                class="search-input"
              >
                <el-option
                  v-for="dict in supervisorList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </div>
            <div class="search-item">
              <el-button type="primary" @click="getdangerlist"
                ><img src="@/assets/images/search.png" alt="" /> 搜索</el-button
              >
              <el-button color="#eff3ff" :dark="true" @click="reset"
                ><img src="@/assets/images/reset.png" alt="" />
                <span style="color: #6d98fd">重置 </span>
              </el-button>
            </div>
            <div class="search-item">
              <el-select
                v-model="params.taskSource"
                placeholder="请选择任务来源"
                clearable
                class="search-input"
              >
                <el-option
                  v-for="dict in sourceList"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </div>
            <div class="search-item">
              <el-date-picker
                v-model="params.dateRange"
                type="daterange"
                align="right"
                range-separator="至"
                start-placeholder="检查开始日期"
                end-placeholder="检查结束日期"
                format="YYYY/MM/DD"
                value-format="YYYY-MM-DD"
              />
            </div>
            <div class="search-item">
              <el-select
                v-model="params.policeStationId"
                placeholder="请选择检查单位"
                clearable
                class="search-input"
              >
                <el-option
                  v-for="dict in policeList"
                  :key="dict.deptId"
                  :label="dict.deptName"
                  :value="dict.deptId * 1"
                />
              </el-select>
            </div>
          </div>
        </div>
      </div>

      <div class="container-table">
        <!-- 表格筛选 -->
        <div class="filter">
          <div
            class="filter-item"
            :class="activeindex === 1 ? 'active' : ''"
            @click="handlerfilter(1)"
          >
            <img
              src="@/assets/images/waitcheck.png"
              alt=""
              srcset=""
              v-if="activeindex === 1"
            />
            <img
              src="@/assets/images/bluewaitcheck.png"
              alt=""
              srcset=""
              v-else
            />

            <div class="item-text">待处理 （{{ notInspect || 0 }}）</div>
          </div>
          <div
            class="filter-item"
            :class="activeindex === 2 ? 'active' : ''"
            @click="handlerfilter(2)"
          >
            <img
              src="@/assets/images/check.png"
              alt=""
              srcset=""
              v-if="activeindex === 2"
            />
            <img src="@/assets/images/bluecheck.png" alt="" srcset="" v-else />

            <div class="item-text">已处理 （{{ inspected || 0 }}）</div>
          </div>
          <div
            class="filter-item"
            :class="activeindex === 3 ? 'active' : ''"
            @click="handlerfilter(3)"
          >
            <img
              src="@/assets/images/check.png"
              alt=""
              srcset=""
              v-if="activeindex === 3"
            />
            <img src="@/assets/images/bluecheck.png" alt="" srcset="" v-else />

            <div class="item-text">发起的 （{{ firstFlag || 0 }}）</div>
          </div>
        </div>
        <!-- 表格数据 -->
        <el-table
          v-loading="loading"
          :data="dangerList"
          border
          height="52vh"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="操作"
            :show-overflow-tooltip="true"
            width="150"
            :resizable="false"
          >
            <template #default="{ row }">
              <div class="table-operate">
                <span class="detail" @click="handleOperate('detail', row)"
                  >详情</span
                >
              </div>
            </template>
          </el-table-column>
          <el-table-column
            label="单位名称"
            prop="name"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="行政区划"
            prop="areaName"
            width="300"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="单位类型"
            prop="institutionType"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="检查单位"
            prop="policeStationName"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="任务来源"
            prop="taskSourceName"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="不达标/达标事项"
            prop="policeStationName"
            :show-overflow-tooltip="true"
          >
            <template #default="{ row }">
              <span style="color: #e7350f">{{ row.notStandard }}</span
              >项/ <span style="color: #2f9a78">{{ row.standard }}</span
              >项
            </template>
          </el-table-column>
          <el-table-column
            label="处置状态"
            prop="checkStatus"
            :show-overflow-tooltip="true"
            width="100"
          >
            <template #default="{ row }">
              {{
                row.checkStatus == 0
                  ? "无需处置"
                  : row.checkStatus == 1
                  ? "处置中"
                  : row.checkStatus == 2
                  ? "已处置"
                  : ""
              }}
            </template>
          </el-table-column>
          <el-table-column
            label="检查时间"
            prop="checkDate"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <pagination
          class="pagination"
          :total="total"
          v-model:page="params.pageNum"
          v-model:limit="params.pageSize"
          @pagination="getdangerlist"
        />
      </div>
    </div>
    <!-- 隐患处置详情 -->
    <el-dialog
      v-model="showdialog"
      width="1000px"
      append-to-body
      class="dialogBox"
    >
      <template #header="{ close, titleId, titleClass }">
        <div class="my-header">
          <img src="@/assets/images/title-card.png" alt="" />
          <div class="header-title">隐患处置</div>
        </div>
      </template>
      <Taskdtl ref="taskdetailref" pageType="danger"></Taskdtl>
      <template #footer>
        <div class="dialog-footer">
          <el-button
            type="success"
            v-if="[2].includes(userStore.deptType) && rowdata.followStatus == 0"
            @click="handlerTaskDisposal(1)"
            >办理</el-button
          >
          <el-button
            type="warning"
            v-if="[1].includes(userStore.deptType) && rowdata.followStatus == 0"
            @click="handlerTaskDisposal(4)"
            >复核</el-button
          >
          <el-button
            color="#626aef"
            :dark="true"
            v-if="
              userStore.cityId &&
              [0].includes(userStore.deptType) &&
              rowdata.followStatus == 0
            "
            @click="handlerTaskDisposal(3)"
            >上报</el-button
          >
          <el-button
            type="info"
            v-if="[0].includes(userStore.deptType) && rowdata.followStatus == 0"
            @click="handlerTaskDisposal(0)"
            >转派</el-button
          >
          <el-button
            type="danger"
            v-if="[2].includes(userStore.deptType) && rowdata.followStatus == 0"
            @click="handlerTaskDisposal(2)"
            >退回</el-button
          >
        </div>
      </template>
    </el-dialog>

    <!-- 操作弹窗 -->
    <el-dialog
      v-model="showoperdialog"
      width="800px"
      append-to-body
      class="dialogBox"
    >
      <template #header="{ close, titleId, titleClass }">
        <div class="my-header">
          <img src="@/assets/images/title-card.png" alt="" />
          <div class="header-title">{{ dialogtitle }}</div>
        </div>
      </template>

      <div class="ope-content">
        <el-form
          :model="operateform"
          ref="operateformRef"
          :rules="queryRules"
          label-width="130px"
          label-position="top"
        >
          <!-- 办理 -->
          <div v-if="operateform.operationType == 1">
            <el-form-item label="处理意见：" prop="content" label-width="130">
              <el-input
                v-model="operateform.content"
                type="textarea"
                rows="4"
                maxlength="100"
                placeholder="请填写"
              ></el-input>
            </el-form-item>
            <el-form-item label="相关照片：" prop="picList" label-width="130">
              <el-input v-model="operateform.picList" v-show="false"></el-input>
              <div>
                <div class="form-upload">
                  <div>
                    <el-upload
                      ref="uploadRef"
                      :action="uploadUrl"
                      :show-file-list="false"
                      accept=".png,.jpg,.jpeg"
                      multiple
                      :headers="myHeaders"
                      :on-success="uploadSuccess"
                      :before-upload="beforeUpload"
                    >
                      <img
                        src="@/assets/images/upload-images.png"
                        alt=""
                        ref="imgRef"
                      />
                    </el-upload>
                    <el-progress
                      v-if="isUpload"
                      status="success"
                      :percentage="100"
                      :format="format"
                      :indeterminate="true"
                      style="width: 80%"
                    />
                  </div>

                  <div class="tooltip">
                    <span>请上传JPG/PNG/JPEG格式文件</span>
                    <span>建议大小小于5M</span>
                    <span>最多上传5张</span>
                  </div>
                </div>
                <div class="upload-pics">
                  <div
                    class="pic"
                    v-for="(item, index) in picList"
                    :key="index"
                  >
                    <img :src="item.url" :alt="item.name" />
                    <div class="operate">
                      <span style="cursor: pointer" @click="replacepic(index)"
                        >替换</span
                      >
                      <span>|</span>
                      <span style="cursor: pointer" @click="delpic(index)"
                        >删除</span
                      >
                    </div>
                  </div>
                </div>
              </div>
            </el-form-item>
          </div>
          <!-- 转派 -->
          <div v-if="operateform.operationType == 0">
            <el-form-item label="主管单位：" prop="deptIds" label-width="130">
              <el-select
                v-model="operateform.deptIds"
                placeholder="请选择主管单位"
                clearable
                style="width: 100%"
              >
                <el-option
                  v-for="dict in chargeList"
                  :key="dict.deptId"
                  :label="dict.deptName"
                  :value="dict.deptId * 1"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="处理意见：" prop="content" label-width="130">
              <el-input
                v-model="operateform.content"
                type="textarea"
                rows="4"
                maxlength="100"
                placeholder="请填写"
              ></el-input>
            </el-form-item>
          </div>
          <!-- 上报和退回 -->
          <div
            v-if="
              operateform.operationType == 2 || operateform.operationType == 3
            "
          >
            <el-form-item label="处理意见：" prop="content" label-width="130">
              <el-input
                v-model="operateform.content"
                type="textarea"
                rows="4"
                maxlength="100"
                placeholder="请填写"
              ></el-input>
            </el-form-item>
          </div>
          <!-- 复核 -->
          <div v-if="operateform.operationType == 4">
            <el-form-item
              label="处理结果："
              prop="businessResult"
              label-width="130"
            >
              <el-radio-group v-model="operateform.businessResult">
                <el-radio :label="1">通过</el-radio>
                <el-radio :label="2">驳回</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="处理意见：" prop="content" label-width="130">
              <el-input
                v-model="operateform.content"
                type="textarea"
                rows="4"
                maxlength="100"
                placeholder="请填写"
              ></el-input>
            </el-form-item>
            <el-form-item label="相关照片：" prop="picList" label-width="130">
              <div class="form-upload">
                <el-input
                  v-model="operateform.picList"
                  v-show="false"
                ></el-input>
                <div>
                  <el-upload
                    ref="uploadRef"
                    :action="uploadUrl"
                    :show-file-list="false"
                    accept=".png,.jpg,.jpeg"
                    :limit="10"
                    multiple
                    :headers="myHeaders"
                    :on-success="uploadSuccess"
                    :before-upload="beforeUpload"
                  >
                    <img
                      src="@/assets/images/upload-images.png"
                      alt=""
                      ref="imgRef"
                    />
                  </el-upload>
                  <el-progress
                    v-if="isUpload"
                    status="success"
                    :percentage="100"
                    :format="format"
                    :indeterminate="true"
                    style="width: 80%"
                  />
                </div>

                <div class="tooltip">
                  <span>请上传JPG/PNG/JPEG格式文件</span>
                  <span>建议大小小于5M</span>
                  <span>最多上传5张</span>
                </div>
              </div>
              <div class="upload-pics">
                <div class="pic" v-for="(item, index) in picList" :key="index">
                  <img :src="item.url" :alt="item.name" />
                  <div class="operate">
                    <span style="cursor: pointer" @click="replacepic(index)"
                      >替换</span
                    >
                    <span>|</span>
                    <span style="cursor: pointer" @click="delpic(index)"
                      >删除</span
                    >
                  </div>
                </div>
              </div>
            </el-form-item>
          </div>
        </el-form>
      </div>

      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleoperateSave">确 定</el-button>
          <el-button @click="handlerback">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import Card from "@/components/Card";
import Taskdtl from "../task/taskdtl";
import {
  getWarnList,
  updateTaskDisposal,
  WarnDisposalCount,
} from "@/api/danger/danger";
import { getDictsApi, getAreaList } from "@/api/dict";
import { selectDeptListByUser } from "@/api/erp/unit";
import { getToken } from "@/utils/auth";
import { ElMessage, ElMessageBox } from "element-plus";
import useUserStore from "@/store/modules/user";
import { useRouter } from "vue-router";

const router = useRouter();
const userStore = useUserStore();
const { proxy } = getCurrentInstance();

// 搜索参数
let params = reactive({
  pageNum: 1,
  pageSize: 20,
  name: "",
  typeId: "",
  levelId: "",
  industryId: "",
  taskSource: "",
  policeStationId: "",
  region: [],
  dateRange: [],
  provinceId: "",
  cityId: "",
  zoneId: "",
  streetId: "",
  tempStatus: 1,
});

// 总数
const total = ref(0);

//行政区划数据
let options = ref([]);

const areaprops = {
  lazy: true,
  checkStrictly: true,
  lazyLoad(node, resolve) {
    const { level } = node;
    let datas = [];
    setTimeout(() => {
      let code = 1;
      if (level != 0) {
        code = node.data.value;
      }
      getAreaList({ pid: code }).then((response) => {
        if (response.data && response.data.length) {
          datas = response.data.map((item, i) => ({
            value: item.value,
            label: item.label,
            leaf: level >= 2,
            // disabled: level == 0, // 这里可以设置为 true 来禁用这个选项
          }));
        } else {
          datas = [];
        }
        resolve(datas);
      });
    }, 200);
  },
};

// 表格加载效果
const loading = ref(false);
//检查列表
const dangerList = ref([]);
//时间选择

// 单位类型下拉
const unittypeList = ref([]);
// 单位级别下拉
const unitlevelList = ref([]);
// 所属行业下拉
const supervisorList = ref([]);
//任务来源下拉
const sourceList = ref([]);
//检查单位下拉
const policeList = ref([]);
//主管单位下拉
const chargeList = ref([]);
// 详情弹窗的显隐
let showdialog = ref(false);
//操作弹窗的显隐
let showoperdialog = ref(false);
//选中的项
let activeindex = ref(1);

//详情组件的引用
const taskdetailref = ref(null);
//处置任务的引用
const operateformRef = ref(null);
let operateform = ref({
  // 操作业务类型 ：0-转派；1-办理 2-退回 3-上报 4-复核
  operationType: "",
  nodeTaskDisposalId: "",
  deptIds: "",
});
//图片校验规则
const picsValidate = (rule, value, callback) => {
  if (!operateform.value.picList || operateform.value.picList == 0) {
    callback(new Error("请上传图片"));
  } else {
    callback();
  }
};
const queryRules = ref({
  content: [{ required: true, message: "请输入处理意见", trigger: "blur" }],
  deptIds: [{ required: true, message: "请选择主管单位！", trigger: "change" }],
  businessResult: [
    { required: true, message: "请选择处理结果！", trigger: "change" },
  ],
  picList: [
    {
      required: true,
      validator: picsValidate,
      trigger: "change",
    },
  ],
});

let isUpload = ref(false);
//上传图片的地址
const uploadUrl = import.meta.env.VITE_APP_BASE_API + "/file/upload";

const myHeaders = ref({
  Authorization: "Bearer " + getToken(),
});

let picList = ref([]);

//上传的状态
let uploadstatus = ref("add");
let replaceindex = ref(0);
let indexToReplace = ref(0);
const format = (percentage) =>
  percentage === 100 ? "上传中……" : `${percentage}%`;
const uploadSuccess = (res) => {
  console.log("chenggon", res);
  if (res.code == 200) {
    ElMessage.success("图片上传成功！");
    isUpload.value = false;
    if (uploadstatus.value == "add") {
      picList.value.push(res.data);
      operateform.value.picList = picList.value.length;
    } else {
      console.log("zhixing");
      picList.value.splice(indexToReplace.value, 1, res.data);
      operateform.value.picList = picList.value.length;
      uploadstatus.value = "add";
    }
  } else {
    isUpload.value = false;
    proxy.$modal.msgError("文件上传失败！");
  }
};

function beforeUpload(file) {
  console.log("file", file);
  if (picList.value.length > 4) {
    ElMessage.error(`最多只能上传5张图片`);
    return false;
  }
  if (file.name.length > 50) {
    ElMessage.error(`文件名过长！最多只能上传50个文字的文件名文件！`);
    return false;
  }
  isUpload.value = true;
}

/**
 * @description: 替换图片
 */
let uploadRef = ref(null);
const replacepic = (index) => {
  uploadstatus.value = "replace";
  indexToReplace.value = index;
  uploadRef.value.$el.querySelector("input").click();
};
/**
 * @description: 删除图片
 */
const delpic = (index) => {
  picList.value.splice(index, 1);
  operateform.value.picList = picList.value.length;
};
/**
 * @description: 序号
 * @param {Number} index 索引
 */
function indexMethod(index) {
  const currentPage = params.pageNum;
  const pageSize = params.pageSize;
  const truelndex = (currentPage - 1) * pageSize + index + 1;
  return truelndex;
}

/**
 * @description: 表格数据接口
 */
const getdangerlist = () => {
  loading.value = true;
  if (params.dateRange) {
    if (params.dateRange.length > 0) {
      params.startDate = params.dateRange[0];
      params.endDate = params.dateRange[1];
    }
  } else {
    params.dateRange = [];
    params.startDate = "";
    params.endDate = "";
  }
  getWarnList(
    { pageNum: params.pageNum, pageSize: params.pageSize },
    params
  ).then((res) => {
    dangerList.value = res.rows;
    total.value = res.total;
    loading.value = false;
    getWarnDisposalCount();
  });
};

/**
 * @description: 状态数据
 */
let firstFlag = ref(0);
let inspected = ref(0);
let notInspect = ref(0);
const getWarnDisposalCount = () => {
  WarnDisposalCount(
    { pageNum: params.pageNum, pageSize: params.pageSize },
    params
  ).then((res) => {
    firstFlag.value = res.data.firstFlag;
    inspected.value = res.data.inspected;
    notInspect.value = res.data.notInspect;
  });
};

/**
 * @description: 重置
 */
const reset = () => {
  Object.assign(params, {
    pageNum: 1,
    pageSize: 20,
    name: "",
    typeId: "",
    levelId: "",
    industryId: "",
    taskSource: "",
    policeStationId: "",
    region: [],
    dateRange: [],
    endDate: "",
    startDate: "",
    provinceId: "",
    cityId: "",
    zoneId: "",
    streetId: "",
    tempStatus: 1,
  });
  getdangerlist();
  activeindex.value = 1;
};

/**
 * @description: tab操作
 */
const handlerfilter = (index) => {
  activeindex.value = index;
  params.tempStatus = index;

  getdangerlist();
};

/**
 * @description: 联级处理省市区操作
 * @param {String} type 类型
 */
const handlerregion = (value) => {
  if (value) {
    switch (value.length) {
      case 1:
        params.provinceId = value[0];
        break;
      case 2:
        params.provinceId = value[0];
        params.cityId = value[1];
        break;
      case 3:
        params.provinceId = value[0];
        params.cityId = value[1];
        params.zoneId = value[2];
        break;
      case 4:
        params.provinceId = value[0];
        params.cityId = value[1];
        params.zoneId = value[2];
        params.streetId = value[3];
        break;

      default:
        break;
    }
  } else {
    params.region = [];
    params.provinceId = null;
    params.cityId = null;
    params.zoneId = null;
    params.streetId = null;
  }
};
/**
 * @description: 重置为初始状态
 */
const resetall = () => {
  //导入分页数据
  ImporttableList.value = [];
  //正常的数据
  normalData.value = [];
  //重复的数据
  repeatData.value = [];
  //异常的数据
  abnormalData.value = [];
  importsuccess.value = false;
};
/**
 * @description: 表格操作
 * @param {String} type 类型
 * @param {Object} row  当前行数据
 */
let rowdata = ref({});
const handleOperate = async (type, row) => {
  switch (type) {
    case "detail":
      rowdata.value = row;
      showdialog.value = true;
      nextTick(() => {
        taskdetailref.value.handleDetailInfo(row);
      });
      break;

    default:
      break;
  }
};
/**
 * @description:  处置任务操作
 */
let dialogtitle = ref("");
const handlerTaskDisposal = (type) => {
  switch (type) {
    case 0:
      dialogtitle.value = "转派";
      break;
    case 1:
      dialogtitle.value = "办理";
      break;
    case 2:
      dialogtitle.value = "退回";
      break;
    case 3:
      dialogtitle.value = "上报";
      break;
    case 4:
      dialogtitle.value = "复核";
      break;

    default:
      break;
  }
  operateform.value.operationType = type;
  showoperdialog.value = true;
};
/**
 * @description:  处置任务保存
 */
const handleoperateSave = () => {
  operateformRef.value.validate(async (valid, fields) => {
    if (valid) {
      ElMessageBox.confirm("确定保存以上数据吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        confirmButtonClass: "confirmBtnClass",
        cancelButtonClass: "cancelBtnClass",
      })
        .then(async () => {
          console.log("rowdata.value", rowdata.value);
          console.log("operateform.value", operateform.value);
          let obj = JSON.parse(JSON.stringify(operateform.value));
          obj.nodeTaskDisposalId = rowdata.value.nodeTaskDisposalId;
          if (operateform.value.operationType == 0) {
            obj.deptIds = [operateform.value.deptIds];
          } else {
            obj.deptIds = [];
          }
          obj.taskId = rowdata.value.taskId;
          obj.taskDisposalId = rowdata.value.taskDisposalId;
          obj.institutionName = rowdata.value.name;
          if (
            operateform.value.operationType == 1 ||
            operateform.value.operationType == 4
          ) {
            obj.fileList = picList.value;
          }
          updateTaskDisposal(obj).then((res) => {
            if (res.code == 200) {
              ElMessage.success(res.msg);
              showoperdialog.value = false;
              showdialog.value = false;
              operateform.value = {
                operationType: "",
                nodeTaskDisposalId: "",
                deptIds: "",
              };
              getdangerlist();
              resetdialogdata();
            } else {
              ElMessage.error(res.msg);
            }
          });
        })
        .catch(() => {});
    }
  });
};
/**
 * @description:  取消
 */
const handlerback = () => {
  showoperdialog.value = false;
  resetdialogdata();
};
/**
 * @description:  重置数据
 */
const resetdialogdata = () => {
  operateform.value = {
    // 操作业务类型 ：0-转派；1-办理 2-退回 3-上报 4-复核
    operationType: "",
    nodeTaskDisposalId: "",
    deptIds: "",
  };
  picList.value = [];
};
/**
 * @description:  获取检查单位
 * @param {Number} id
 */
const getpolicestation = (deptType) => {
  let obj = {
    deptType: deptType,
    provinceId: userStore.provinceId,
    cityId: userStore.cityId,
    zoneId: userStore.zoneId,
    streetId: userStore.streetId,
  };
  selectDeptListByUser(obj).then((res) => {
    if (deptType == 1) {
      policeList.value = res.data;
    } else {
      chargeList.value = res.data;
    }
  });
};
/**
 * @description: 获取字典
 */
async function getDicts() {
  await getDictsApi("institution_type").then((res) => {
    //单位类型下拉
    if (res.code === 200) {
      unittypeList.value = res.data;
    }
  });
  await getDictsApi("institution_industry_type").then((res) => {
    //行业主管下拉
    if (res.code === 200) {
      supervisorList.value = res.data;
    }
  });
  await getDictsApi("fkwz_institution_level_type").then((res) => {
    //单位级别下拉
    if (res.code === 200) {
      unitlevelList.value = res.data;
    }
  });
  await getDictsApi("task_source_type").then((res) => {
    //任务来源下拉
    if (res.code === 200) {
      sourceList.value = res.data;
    }
  });
  getpolicestation(1);
  getpolicestation(2);
  // await getAreaList({ pid: 0 }).then((res) => {
  //   options.value = res.data;
  // });
}

onMounted(() => {
  getdangerlist();
  getWarnDisposalCount();
  getDicts();
  if (router.currentRoute.value.query.businessId) {
    handleOperate("detail", {
      taskId: router.currentRoute.value.query.businessId,
    });
    // 使用 replace 方法更新路由
    router.replace({
      query: {},
    });
  }
});
</script>

<style scoped lang="scss">
.container {
  position: relative;
  .container-search {
    margin-bottom: 12px;
    .container-search-bottom {
      background-color: #ffffff;
      border-radius: 10px;
      padding: 15px 15px 15px 15px;
    }
  }

  .container-button {
    position: absolute;
    top: 15px;
    right: 15px;
    img {
      margin-right: 6px;
      margin-top: 2px;
    }
  }
  .container-table {
    background-color: #ffffff;
    border-radius: 10px;
    padding: 15px 15px 15px 15px;
    .filter {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 460px;
      background: #ffffff;
      box-shadow: 0px 1px 4px 0px rgba(51, 51, 51, 0.1);
      border-radius: 20px;
      font-size: 14px;
      padding: 2px;
      margin-bottom: 10px;
      .filter-item {
        cursor: pointer;
        display: flex;
        align-items: center;
        padding: 10px 20px;
        border-radius: 20px;
        color: #7eb7fe;
        img {
          height: 16px;
          margin-right: 2px;
        }
      }
      .active {
        background-color: #4aa1fe;
        color: #ffffff;
      }
    }
    .check-tab {
      display: flex;
      .tab-item {
        display: flex;
        .tab {
          padding: 4px 12px;
          margin-right: 10px;
        }
        .tab-time {
          width: 110px;
          padding: 4px 12px;
        }
      }
      .orange {
        color: #ef8e4d;
        background-color: #f7e3c3;
        border-radius: 5px;
      }
      .green {
        color: #60cba7;
        background-color: #bbeddc;
        border-radius: 5px;
      }
    }
  }
}
.ope-content {
  padding: 10px 30px 20px 30px;
  .form-upload {
    display: flex;
    .tooltip {
      display: flex;
      justify-content: space-between;
      flex-direction: column;
      height: 66px;
      font-size: 14px;
      color: #999999;
      margin-left: 20px;
    }
  }
  .upload-pics {
    display: flex;
    margin-top: 20px;
    width: 800px;
    flex-wrap: wrap;
    .pic {
      position: relative;
      width: 160px;
      height: 100px;
      display: flex;
      justify-content: center;
      margin-right: 10px;
      img {
        width: 100%;
        height: 100%;
      }
      .operate {
        display: flex;
        align-items: center;
        justify-content: space-around;
        position: absolute;
        bottom: 10px;
        margin: 0 auto;
        font-size: 14px;
        background: rgba(0, 0, 0, 0.4);
        color: #fff;
        width: 120px;
        height: 30px;
      }
    }
  }
}
</style>

<style>
.ImportdialogBox {
  .el-pagination {
    margin-top: 20px;
    justify-content: center;
  }
}
</style>
